package com.sun.dream.fish.controller;

import com.sun.dream.fish.service.IMenuService;
import com.sun.dream.fish.vo.ResultVO;
import com.sun.dream.fish.vo.back.MenuData;
import com.sun.dream.fish.vo.back.MenuVO;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    IMenuService menuService;

    @PostMapping("/add")
    public ResultVO addMenu(@RequestBody MenuVO menuVO) {
        return menuService.addMenu(menuVO);
    }

    @GetMapping("/list")
    public ResultVO<MenuData> listMenu() {
        return menuService.listMenu();
    }

    @GetMapping("/getRoleMenu")
    public ResultVO<MenuData> getRoleMenu() {
        return menuService.listRoleMenu();
    }

    @GetMapping("/getById")
    public ResultVO<MenuVO> getById(@RequestParam("id") Integer id) {
        return menuService.getById(id);
    }

    @DeleteMapping("/deleteById")
    public ResultVO<MenuVO> deleteById(@RequestParam("id") Integer id) {
        return menuService.deleteById(id);
    }

    @PutMapping("/updateById")
    public ResultVO<MenuVO> updateById(@RequestBody MenuVO menuVO) {
        return menuService.updateById(menuVO);
    }

}
